#include "tool.h"
#include "stdio.h"
#include "usart.h"

void delay_us(uint16_t us)
{
	uint16_t tmp_us = 0;
	
	__HAL_TIM_SetCounter(&MY_TIMER,0);
	
	HAL_TIM_Base_Start(&MY_TIMER);
	
	do 
	{
		tmp_us = __HAL_TIM_GetCounter(&MY_TIMER);
	}while(tmp_us<us);

	HAL_TIM_Base_Stop(&MY_TIMER);
	
}

void delay_ms(uint16_t ms)
{
	
	delay_us(ms * 1000);
	
}

int fputc(int ch, FILE *f)
{
	
  HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0x01);
 
  return ch;
}
